<?php



namespace App\Http\Requests\Company;


use App\Services\Base\Services\ConfigService;
use App\Services\Base\Interfaces\ConfigServiceInterface;
use Carbon\Carbon;
use Illuminate\Support\Facades\Auth;

class CompanyRequest extends BaseRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name' => 'required|max:10',

        ];
    }

    public function messages()
    {
        return [
            'name.required' => __('请输入店铺的名称'),

        ];
    }

    public function filldata()
    {
        $user= Auth::user();
        /**
         *# @var  ConfigService $configService
         *
         * */
        $configService = app()->make(ConfigServiceInterface::class);
        return [
            'user_id'=>(int)$user['id'],
            'mobile'=>(int)$this->input('mobile',$user['mobile']),
            'logo'=>(string)$this->input('logo')?:$configService->getCompanyDefaultLogo(),
            'background'=>(string)$this->input('background')?:$configService->getCompanyDefaultBackground(),
            'coordinates'=>(string)json_encode($this->input('coordinates')),
            'address'=>(string)$this->input('address'),
            'role_id'=>1,
            'expired_at' =>Carbon::now()->addDay(7),
            'is_trial_version'=>$this->input('is_trial_version',1),
            'description'=>(string)$this->input('description'),
            'introduction'=>(string)$this->input('introduction'),
            'uuid'=>(string) 'so'.time().rand(1000, 9999),
            'name' =>(string) $this->input('name', ''),
            'category_id'=>(int)$this->input('category_id',0),
            'contact'=>(string)$this->input('contact',''),
            'company_id'=>(int)$this->input('company_id'),
            'corp_id'=>(string)$this->input('corp_id'),
            'work_wechat_id'=>(string)$this->input('work_wechat_id'),


        ];
    }
}
